package com.xy.biz.fd.domain.converter;

import java.util.Collection;
import java.util.List;

import com.xy.biz.fd.domain.bo.DocumentFavoriteBO;
import com.xy.biz.fd.domain.po.DocumentFavoritePO;
import com.xy.biz.fd.domain.query.DocumentFavoriteQuery;
import com.xy.biz.fd.domain.resp.GetDocumentFavoriteResponse;
import com.xy.biz.fd.domain.req.documentFavorite.SaveDocumentFavoriteRequest;
import com.xy.biz.fd.domain.req.documentFavorite.ListDocumentFavoriteRequest;
import com.xy.tool.util.BeanUtilsEx;

/**
 * 
 * 
 * @author wwj
 * @date 2021-2-2
 */
public class DocumentFavoriteConverter {
	
	public static DocumentFavoritePO toPO(DocumentFavoriteBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFavoritePO(), true);
	}
	
	public static List<DocumentFavoritePO> toPO(Collection<DocumentFavoriteBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFavoritePO(), true);
	}
	
	public static DocumentFavoriteBO fromPO(DocumentFavoritePO source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFavoriteBO());
	}
	
	public static List<DocumentFavoriteBO> fromPO(Collection<DocumentFavoritePO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFavoriteBO());
	}
	
	public static DocumentFavoriteBO toBO(SaveDocumentFavoriteRequest source) {
		return BeanUtilsEx.copyProperties(source, () -> new DocumentFavoriteBO(), true);
	}
	
	public static List<DocumentFavoriteBO> toBO(Collection<SaveDocumentFavoriteRequest> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new DocumentFavoriteBO(), true);
	}
	
	public static GetDocumentFavoriteResponse toResponse(DocumentFavoriteBO source) {
		return BeanUtilsEx.copyProperties(source, () -> new GetDocumentFavoriteResponse());
	}
	
	public static List<GetDocumentFavoriteResponse> toResponse(Collection<DocumentFavoriteBO> source) {
		return BeanUtilsEx.copyPropertiesForNewList(source, () -> new GetDocumentFavoriteResponse());
	}
	
	public static DocumentFavoriteQuery toQuery(ListDocumentFavoriteRequest source) {
		if(null == source) {
			return null;
		}
		DocumentFavoriteQuery target = new DocumentFavoriteQuery(source.getPageIndex(), source.getPageSize());
		BeanUtilsEx.copyProperties(source, target);
		return target;
	}

}
